//
//  SingerAnd3DViewController.m
//  Gegeda_music_MY
//
//  Created by lanou3g on 15/11/2.
//  Copyright © 2015年 周莹. All rights reserved.
//

#define k_FontSize         (arc4random() % 20) + 12
#import "SingerAnd3DViewController.h"
#import "AllViewController.h"

@interface SingerAnd3DViewController ()

@end

@implementation SingerAnd3DViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationController.navigationBar.translucent = NO;
    [self labelCloud];
    
}

-(void)labelCloud
{
    NSArray *colorArray = @[[UIColor greenColor],[UIColor blueColor],[UIColor purpleColor],[UIColor redColor],[UIColor grayColor],[UIColor magentaColor],[UIColor brownColor]];
    NSMutableArray *titlesArray = [[NSMutableArray alloc] initWithObjects:@"全部",@"日本",@"欧美",@"华语",@"韩国",@"音乐人",@"翻唱",@"电影原声",@"其他", nil];
    NSMutableArray *frameArray = [[NSMutableArray alloc] initWithObjects:@"{{54, 92}, {120, 30}}",@"{{26, 228}, {120, 30}}",@"{{132, 124}, {120, 30}}",@"{{64, 146}, {120, 30}}",@"{{180, 175}, {120, 30}}",@"{{54, 190}, {120, 30}}",@"{{132, 238}, {120, 30}}",@"{{170, 269}, {120, 30}}",@"{{47, 290}, {120, 30}}", nil];
    for (UILabel *label in [self.view subviews]) {
        label.text = [titlesArray objectAtIndex:0];
        [titlesArray removeObjectAtIndex:0];
        label.textColor = colorArray[arc4random()%[colorArray count]];
        label.font = [UIFont systemFontOfSize:k_FontSize];
        label.frame = CGRectZero;
        label.center = self.view.center;
        label.userInteractionEnabled = YES;
        
        [UIView animateWithDuration:2 animations:^{
            label.frame = CGRectFromString(frameArray[0]);
            [frameArray removeObjectAtIndex:0];
        } completion:nil];
        
        // 监听点击
        [label addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick:)]];

    }
}
/**
 *  监听label的点击
 */
- (void)labelClick:(UITapGestureRecognizer *)recognizer
{
    // 获得被点击的label
    UILabel *label = (UILabel *)recognizer.view;
    
    //初始化控制器
    AllViewController *vc = [[AllViewController alloc] init];
    
    switch (label.tag) {
            
        case 0:
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"全部";
            break;
            
        case 1:
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"日本";
            break;
            
        case 2:
            
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"欧美";
            break;
            
        case 3:
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"华语";
            break;
            
        case 4:
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"韩国";
            break;
            
        case 5:
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"其他";
            break;
            
        case 6:
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"音乐人";
            break;
            
        case 7:
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"翻唱";
            break;
            
        case 8:
            [self.navigationController pushViewController:vc animated:YES];
            vc.title = @"电影原声";
            break;
            
        default:
            break;
    }
    vc.index = label.tag;
}

@end
